package easy;

import java.util.HashMap;
import java.util.Map;

public class Solution_5922 {
    public int countWords(String[] words1, String[] words2) {
        Map<String, Integer> map = new HashMap<>();
        for (String s : words1) {
            Integer integer = map.get(s);
            if (integer == null) {
                map.put(s, 1);
            } else {
                map.put(s, 2);
            }
        }
        for (String s : words2) {
            Integer integer = map.get(s);
            if (integer == null || integer == 2 || integer > 20) {
            } else {
                if (integer < 10) {
                    map.put(s, 11);
                } else {
                    map.put(s, 21);
                }
            }
        }
        int count = 0;
        for (String s : map.keySet()) {
            if (map.get(s) == 11) {
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Solution_5922 model = new Solution_5922();
        System.out.println(model.countWords(new String[]{"leetcode", "is", "amazing", "as", "is"}, new String[]{"amazing", "leetcode", "is"}));
        System.out.println(model.countWords(new String[]{"b", "bb", "bbb"}, new String[]{"a", "aa", "aaa"}));
        System.out.println(model.countWords(new String[]{"a", "ab"}, new String[]{"a", "a", "a", "ab"}));
    }
}
